package day10;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import static java.lang.System.*;

public class MyMap1 {
    public static void main(String[] args) {
        HashMap<Student1, String> map = new HashMap<>();
        Student1 stu = new Student1("xiaoming", 13);
        Student1 stu1 = new Student1("xiaohua", 16);
        Student1 stu2 = new Student1("daming", 14);
        Student1 stu3 = new Student1("tianming", 14);
        map.put(stu1, "xia");
        map.put(stu2, "di");
        map.put(stu3, "bei");
        map.put(stu, "jin");
        Set<Student1> keySet = map.keySet();
        for (Student1 key : keySet) {
            String value = map.get(key);
            System.out.println(key + value);

        }
        System.out.println("------");
        Set<Map.Entry<Student1, String>> entries = map.entrySet();
        for (Map.Entry<Student1, String> entry : entries) {
            Student1 key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key + value);
        }
        System.out.println("------");
        map.forEach(
                (key, value) ->
                System.out.println(key + value)
        );
    }
}


